package cn.net.lwj.common.util;

import org.doomdark.uuid.UUIDGenerator;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.stereotype.Component;

//@Component(value="createNewKey")
@Component
@ComponentScan
public class CreateNewKey {
 
	public static String getNewKey(){
		return getNewKey(null);
	}
	 
	public static String getNewKey(String fyjbm) {
		fyjbm = fyjbm == null || fyjbm.trim().equals("") ? "0" : fyjbm;
        return fyjbm + UUIDGenerator.getInstance().generateRandomBasedUUID().toString().replaceAll("-", "");
	}

	public static synchronized String createId(){
		return createId(null);
	}
	
	public static synchronized String createId(String fyjbm) {
		fyjbm = fyjbm == null || fyjbm.trim().equals("") ? "" : fyjbm;
		return fyjbm+ UUIDGenerator.getInstance().generateRandomBasedUUID().toString().replaceAll("-","");
	}
}
